package cn.itsource.util;

import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MyBatisUtil {
	static String resource = "mybatis-config.xml"; 
	static SqlSessionFactory ssf = null;
	static{
		try {
			//读取配置文件
			InputStream is = Resources.getResourceAsStream(resource);
			//构建SqlSessionFactory对象
			ssf = new SqlSessionFactoryBuilder().build(is);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static SqlSessionFactory getSession(){
		return ssf;
	}
}
